package com.cafuc.javaEE;

import com.cafuc.javaEE.service.CService;
import com.cafuc.javaEE.service.impl.CServiceImpl;
import com.cafuc.javaEE.util.ConfigUtil2;
import com.cafuc.javaEE.util.JDBCConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

@Configuration
@ComponentScan
public class SpringApp {
    public static void main(String[] args) {
        //读取 xml 配置文件的方式启动 IOC 容器
        // ContextRefreshedEvent event;
        // ApplicationContext applicationContext =
        //         new ClassPathXmlApplicationContext("application.xml");
        // AService aService = applicationContext.getBean(AServiceImpl.class);
        // aService.call();
        ApplicationContext app = new AnnotationConfigApplicationContext(SpringApp.class);
        // CService cService = app.getBean(CServiceImpl.class);
        // cService.ca();
        // ConfigUtil2 configUtil2 = app.getBean(ConfigUtil2.class);
        // Properties properties = configUtil2.getProperties();
        // System.out.println(properties.getProperty("jdbc.url"));
        JDBCConfig jdbcConfig = app.getBean(JDBCConfig.class);
        System.out.println(jdbcConfig.getDriverClassName());

    }
}
